<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
    <title>登录中</title>
    <link href="libs/weui/weuix.min.css" rel="stylesheet" />
    <style>
        .weui_btn_dialog.primary{color:#de0520}
    </style>
    <script type="text/javascript" src="libs/zepto/zepto.min.js"></script>
    <script type="text/javascript" src="libs/zepto/zepto.cookie.min.js"></script>
    <script src="js/common.js"></script>
</head>
<body>
<div class="weui_msg hide" id='msg3'>
    <div class='weui_msg_box'><p>授权登陆中……</p></div>
</div>
<input type="hidden" id="code" value=""/>
<input type="hidden" id="userId" value=""/>
<script>
        var codeval = GetQueryString('code');
        $("#code").val(codeval);
        $.ajax({
            url:API_URL + WEIXIN_LOGIN_URL,
            type:'post',
            dataType:'jsonp',
            data:{code:codeval},
            success:function(data){
                if(data.ok==true){
                    $.fn.cookie('isLogin', true);
                    $.fn.cookie('token',data.result.token);
                    $.fn.cookie('userId',data.result.user.id);
                    $.toast('登陆成功！');
                    var curUrl = $.fn.cookie('curUrl');
                    setTimeout(function(){
                        window.location.href=curUrl;
                    },1000);
                }else{
                    $.fn.cookie('isLogin',false);
                    $.alert(data.msg);
                }
            }
        })
</script>
</body>
</html>